package models

import "gorm.io/gorm"

type Books struct {
	gorm.Model
	BooksId  int
	Title    string `gorm:"type:varchar(100)" json:"title"`
	Name     string `gorm:"type:varchar(100)" json:"name"`
	Man      string `gorm:"type:varchar(100)" json:"man"`
	Look     string `gorm:"type:varchar(100)" json:"Look"`
	Classify string `gorm:"type:varchar(100)" json:"classify"`
	Time     string `gorm:"type:varchar(100)" json:"time"`
}

// 创建
func (u *Books) Create() error {
	return DB.Create(&u).Error
}

// 展示
func (u *Books) List() error {
	return DB.Where("book_id = ?", u.BooksId).Limit(1).Find(&u).Error
}

// 删除
func (u *Books) Del() error {
	return DB.Where("book_id = ?", u.ID).Delete(&u).Error
}
